14. Types of Merges

Types of Merges

So far, we've learned about appending dataframes. Now we'll learn about pandas Merges , a different way of combining dataframes. This is similar to the database-style "join." If you're familiar with SQL, this comparison with SQL may help you connect these two.

Here are the four types of merges in pandas. Below, "key" refers to common columns in both dataframes that we're joining on.

  1. Inner Join - Use intersection of keys from both frames.
  2. Outer Join - Use union of keys from both frames.
  3. Left Join - Use keys from left frame only.
  4. Right Join - Use keys from right frame only.

Below are diagrams to visualize each type.

Read the documentation for pandas Merges here .